/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrameEntidade.java
 *
 * Created on 13/09/2011, 20:04:34
 */
package br.com.GUI.cadastro;

import br.com.classes.Entidade;
import br.com.dao.EntidadeDao;
import java.text.ParseException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFormattedTextField;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import javax.swing.text.MaskFormatter;
/**
 *
 * @author Kauane
 */
public class FrameEntidade extends javax.swing.JFrame {

    int num = 0;
    int cod_ent;
   MaskFormatter cp = null;
   MaskFormatter DDD = null;
   MaskFormatter Cpf = null;
   MaskFormatter CNPJ = null;
   MaskFormatter Tel = null;
   MaskFormatter Rg = null;
   MaskFormatter Uf = null;
   
    /** Creates new form FrameEntidade */
    public FrameEntidade() {
    
        initComponents();     
        CarregarEntidade();      

    }
  
    public  String formatString(String string)
        throws java.text.ParseException {
    javax.swing.text.MaskFormatter mf =
            new javax.swing.text.MaskFormatter("####-####");
    mf.setValueContainsLiteralCharacters(false);
     System.out.println(mf.valueToString(string));
    return mf.valueToString(string);
       
}
    
    public class LetraMaiuscula extends PlainDocument {  
   
        @Override  
     public void insertString(int offset, String str, AttributeSet attr)  
     throws BadLocationException {  
       super.insertString(offset, str.toUpperCase(), attr);  
     }    
}     
    
       public String limpaString(String x){
    
        x = x.replace(".","");
        x = x.replace("-","");
        x = x.replace("/","");
        x = x.replace("(","");
        x = x.replace(")","");       
        return x;
    
    }

    public void CarregarEntidade() {
      
        EntidadeDao edao = new EntidadeDao();
        List<Entidade> lista = edao.ListarEntidade();
        DefaultTableModel modelo = (DefaultTableModel) jTableConsultaEntidade.getModel();
        modelo.setRowCount(0);

        for (Entidade e : lista) {

          modelo.addRow(new Object[]{e.getCod_ent(), e.getNome_ent(), e.getApelido(), e.getEnd(), e.getTelefone(), e.getBairro(), e.getObs()});       

}
        jTableConsultaEntidade.setModel(modelo);
    }

    public void BuscarLimiteProximo() {
      
        num = num + 10;

        EntidadeDao edao = new EntidadeDao();
        List<Entidade> lista = edao.BuscarLimite(num);

        DefaultTableModel modelo = (DefaultTableModel) jTableConsultaEntidade.getModel();
        modelo.setRowCount(0);

        for (Entidade e : lista) {
         modelo.addRow(new Object[]{e.getCod_ent(), e.getNome_ent(), e.getApelido(), e.getEnd(), e.getTelefone(), e.getBairro(), e.getObs()});
        }

        jTableConsultaEntidade.setModel(modelo);
                 if(lista.size()<10){
        jButtonAvancar.setEnabled(false);
      }
    }

    public void buscarLimiteAnterior() {
     
        num = num - 10;

        EntidadeDao edao = new EntidadeDao();
        List<Entidade> lista = edao.BuscarLimite(num);

        DefaultTableModel modelo = (DefaultTableModel) jTableConsultaEntidade.getModel();
        modelo.setRowCount(0);

        for (Entidade e : lista) {
        modelo.addRow(new Object[]{e.getCod_ent(), e.getNome_ent(), e.getApelido(), e.getEnd(), e.getTelefone(), e.getBairro(), e.getObs()});
        }
        jTableConsultaEntidade.setModel(modelo);
                        if(lista.size()<10){
        jButtonVoltar.setEnabled(false);
      }
    }

    public void CarregarEntidadeLetra() {
        String entidade = jTextField11.getText();
        EntidadeDao edao = new EntidadeDao();

        List<Entidade> lista = edao.ProcurarPorBancoLetra(entidade);

        DefaultTableModel modelo = (DefaultTableModel) jTableConsultaEntidade.getModel();
        modelo.setRowCount(0);

        for (Entidade e : lista) {
        modelo.addRow(new Object[]{e.getCod_ent(), e.getNome_ent(), e.getApelido(), e.getEnd(), e.getTelefone(), e.getBairro(), e.getObs()});
      }
        jTableConsultaEntidade.setModel(modelo);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane2 = new javax.swing.JScrollPane();
        jTableConsultaEntidade = new javax.swing.JTable();
        jButtonCadastrar = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jTextFieldNome = new javax.swing.JTextField();
        jTextFieldEnd = new javax.swing.JTextField();
        jTextFieldBairro = new javax.swing.JTextField();
        jTextFieldCidade = new javax.swing.JTextField();
        jTextField12 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jTextFieldApelido = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jTextFieldCep = new javax.swing.JFormattedTextField();
        jTextFieldDDD = new javax.swing.JFormattedTextField();
        jTextFieldTelefone = new javax.swing.JFormattedTextField();
        jTextFieldRg = new javax.swing.JFormattedTextField();
        jTextFieldIE = new javax.swing.JFormattedTextField();
        jTextFieldCpf = new javax.swing.JFormattedTextField();
        jTextFieldCNPJ = new javax.swing.JFormattedTextField();
        jTextFieldUF = new javax.swing.JFormattedTextField();
        jButtonAtualiza = new javax.swing.JButton();
        jButtonExcluir = new javax.swing.JButton();
        jButtonEditar = new javax.swing.JButton();
        jButtonVoltar = new javax.swing.JButton();
        jButtonAvancar = new javax.swing.JButton();
        jLabel13 = new javax.swing.JLabel();
        jTextField11 = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jLabelEntidade = new javax.swing.JLabel();
        jButtonLimparEntidade = new javax.swing.JButton();

        setMinimumSize(new java.awt.Dimension(770, 620));
        setResizable(false);

        jTableConsultaEntidade.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Nome", "Apelido", "Endereço", "Telefone", "Bairro", "Obs."
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, true
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableConsultaEntidade.getTableHeader().setReorderingAllowed(false);
        jScrollPane2.setViewportView(jTableConsultaEntidade);
        jTableConsultaEntidade.getColumnModel().getColumn(0).setMinWidth(50);
        jTableConsultaEntidade.getColumnModel().getColumn(0).setPreferredWidth(50);
        jTableConsultaEntidade.getColumnModel().getColumn(0).setMaxWidth(50);
        jTableConsultaEntidade.getColumnModel().getColumn(1).setMinWidth(120);
        jTableConsultaEntidade.getColumnModel().getColumn(1).setPreferredWidth(120);
        jTableConsultaEntidade.getColumnModel().getColumn(1).setMaxWidth(120);
        jTableConsultaEntidade.getColumnModel().getColumn(2).setMinWidth(100);
        jTableConsultaEntidade.getColumnModel().getColumn(2).setPreferredWidth(100);
        jTableConsultaEntidade.getColumnModel().getColumn(2).setMaxWidth(100);
        jTableConsultaEntidade.getColumnModel().getColumn(3).setMinWidth(120);
        jTableConsultaEntidade.getColumnModel().getColumn(3).setPreferredWidth(120);
        jTableConsultaEntidade.getColumnModel().getColumn(3).setMaxWidth(120);
        jTableConsultaEntidade.getColumnModel().getColumn(4).setMinWidth(100);
        jTableConsultaEntidade.getColumnModel().getColumn(4).setPreferredWidth(100);
        jTableConsultaEntidade.getColumnModel().getColumn(4).setMaxWidth(100);
        jTableConsultaEntidade.getColumnModel().getColumn(5).setMinWidth(120);
        jTableConsultaEntidade.getColumnModel().getColumn(5).setPreferredWidth(120);
        jTableConsultaEntidade.getColumnModel().getColumn(5).setMaxWidth(120);
        jTableConsultaEntidade.getColumnModel().getColumn(6).setMinWidth(140);
        jTableConsultaEntidade.getColumnModel().getColumn(6).setPreferredWidth(140);
        jTableConsultaEntidade.getColumnModel().getColumn(6).setMaxWidth(140);

        jButtonCadastrar.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jButtonCadastrar.setText("Cadastrar");
        jButtonCadastrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCadastrarActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados Completo do Cliente/Fornecedor"));

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel3.setText("*Nome:");

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel4.setText("*Endereço:");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel5.setText("*Bairro:");

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel6.setText("*Cidade:");

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel7.setText("*CEP:");

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel8.setText("Telefone:");

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel9.setText("*CPF:");

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel10.setText("*RG:");

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel12.setText("Obs.:");

        jTextFieldNome.setDocument(new LetraMaiuscula());

        jTextFieldEnd.setDocument(new LetraMaiuscula());

        jTextFieldBairro.setDocument(new LetraMaiuscula());

        jTextFieldCidade.setDocument(new LetraMaiuscula());

        jTextField12.setDocument(new LetraMaiuscula());
        jTextField12.setHorizontalAlignment(javax.swing.JTextField.LEFT);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel1.setText("DDD:");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel2.setText("UF:");

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel11.setText("*CNPJ:");

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel15.setText("*IE:");

        jTextFieldApelido.setDocument(new LetraMaiuscula());

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel16.setText("*Apelido:");

        try {
            cp = new MaskFormatter("#####-###");
            jTextFieldCep = new JFormattedTextField(cp);
        } catch (ParseException ex) {
            Logger.getLogger(FrameEntidade.class.getName()).log(Level.SEVERE, null, ex);
        }
        jTextFieldCep.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldCepActionPerformed(evt);
            }
        });
        jTextFieldCep.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldCepFocusLost(evt);
            }
        });

        try {
            DDD = new MaskFormatter("(##)");
            jTextFieldDDD = new JFormattedTextField(DDD);
        } catch (ParseException ex) {
            Logger.getLogger(FrameEntidade.class.getName()).log(Level.SEVERE, null, ex);
        }
        jTextFieldDDD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldDDDActionPerformed(evt);
            }
        });
        jTextFieldDDD.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldDDDFocusLost(evt);
            }
        });

        try {
            Tel = new MaskFormatter("####-####");
            jTextFieldTelefone = new JFormattedTextField(Tel);
        } catch (ParseException ex) {
            Logger.getLogger(FrameEntidade.class.getName()).log(Level.SEVERE, null, ex);
        }
        jTextFieldTelefone.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldTelefoneFocusLost(evt);
            }
        });

        try {
            Rg = new MaskFormatter("##.###.###-#");
            jTextFieldRg = new JFormattedTextField(Rg);
        } catch (ParseException ex) {
            Logger.getLogger(FrameEntidade.class.getName()).log(Level.SEVERE, null, ex);
        }
        jTextFieldRg.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldRgFocusLost(evt);
            }
        });

        try {
            Cpf = new MaskFormatter("###.###.###-##");
            jTextFieldCpf = new JFormattedTextField(Cpf);
        } catch (ParseException ex) {
            Logger.getLogger(FrameEntidade.class.getName()).log(Level.SEVERE, null, ex);
        }
        jTextFieldCpf.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldCpfActionPerformed(evt);
            }
        });
        jTextFieldCpf.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldCpfFocusLost(evt);
            }
        });

        try {
            CNPJ = new MaskFormatter("###.###.###/####-##");
            jTextFieldCNPJ = new JFormattedTextField(CNPJ);
        } catch (ParseException ex) {
            Logger.getLogger(FrameEntidade.class.getName()).log(Level.SEVERE, null, ex);
        }
        jTextFieldCNPJ.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldCNPJFocusLost(evt);
            }
        });

        try {
            Uf = new MaskFormatter("UU");
            jTextFieldUF = new JFormattedTextField(Uf);
        } catch (ParseException ex) {
            Logger.getLogger(FrameEntidade.class.getName()).log(Level.SEVERE, null, ex);
        }
        jTextFieldUF.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldUFFocusLost(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(38, 38, 38)
                        .addComponent(jTextFieldNome))
                    .addComponent(jLabel10)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addGap(54, 54, 54)
                        .addComponent(jTextField12, javax.swing.GroupLayout.PREFERRED_SIZE, 596, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel15)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel4)
                            .addComponent(jLabel1)
                            .addComponent(jLabel16))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jTextFieldRg, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                                            .addComponent(jTextFieldIE))
                                        .addGap(33, 33, 33)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING))
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jTextFieldCpf)
                                            .addComponent(jTextFieldCNPJ)))
                                    .addComponent(jTextFieldEnd, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(29, 29, 29))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jTextFieldApelido, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(0, 0, Short.MAX_VALUE))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(jTextFieldCidade, javax.swing.GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(18, 18, 18)
                                                .addComponent(jLabel2))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(jTextFieldDDD, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(18, 18, 18)
                                                .addComponent(jLabel8)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(jTextFieldTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                .addComponent(jTextFieldUF, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(56, 56, 56)))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldCep)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jTextFieldBairro, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE)))))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(10, 10, 10)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldApelido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldBairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5))
                        .addGap(31, 31, 31))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(jTextFieldCidade, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7)
                            .addComponent(jLabel2)
                            .addComponent(jTextFieldCep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldUF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel8)
                    .addComponent(jTextFieldDDD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldTelefone))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(jTextFieldRg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel15)
                                .addGap(13, 13, 13))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jTextFieldIE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(jTextFieldCpf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(jTextFieldCNPJ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12)
                    .addComponent(jTextField12, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jButtonAtualiza.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/refresh.png"))); // NOI18N
        jButtonAtualiza.setBorder(null);
        jButtonAtualiza.setContentAreaFilled(false);
        jButtonAtualiza.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/refresh[2]over.png"))); // NOI18N
        jButtonAtualiza.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAtualizaActionPerformed(evt);
            }
        });

        jButtonExcluir.setBackground(null);
        jButtonExcluir.setForeground(null);
        jButtonExcluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/delete[5].png"))); // NOI18N
        jButtonExcluir.setBorder(null);
        jButtonExcluir.setBorderPainted(false);
        jButtonExcluir.setContentAreaFilled(false);
        jButtonExcluir.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/delete[5]over.png"))); // NOI18N
        jButtonExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonExcluirActionPerformed(evt);
            }
        });

        jButtonEditar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/pencil.png"))); // NOI18N
        jButtonEditar.setBorder(null);
        jButtonEditar.setContentAreaFilled(false);
        jButtonEditar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/pencil[2]over.png"))); // NOI18N
        jButtonEditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEditarActionPerformed(evt);
            }
        });

        jButtonVoltar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/back[2].png"))); // NOI18N
        jButtonVoltar.setBorder(null);
        jButtonVoltar.setContentAreaFilled(false);
        jButtonVoltar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/back[2]over.png"))); // NOI18N
        jButtonVoltar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVoltarActionPerformed(evt);
            }
        });

        jButtonAvancar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/next[2].png"))); // NOI18N
        jButtonAvancar.setBorder(null);
        jButtonAvancar.setContentAreaFilled(false);
        jButtonAvancar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/next[2]over.png"))); // NOI18N
        jButtonAvancar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAvancarActionPerformed(evt);
            }
        });

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel13.setText("Pesquisa Nome:");

        jTextField11.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextField11KeyReleased(evt);
            }
        });

        jLabel14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/search[1].png"))); // NOI18N

        jLabelEntidade.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabelEntidade.setText("Cliente/Fornecedor");

        jButtonLimparEntidade.setText("Limpar");
        jButtonLimparEntidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLimparEntidadeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(28, 28, 28)
                                .addComponent(jLabelEntidade)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 387, Short.MAX_VALUE)
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jTextField11, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jButtonLimparEntidade)
                                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel14))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jButtonVoltar)
                                .addGap(5, 5, 5)
                                .addComponent(jButtonEditar)
                                .addGap(5, 5, 5)
                                .addComponent(jButtonAtualiza)
                                .addGap(5, 5, 5)
                                .addComponent(jButtonExcluir)
                                .addGap(5, 5, 5)
                                .addComponent(jButtonAvancar)
                                .addGap(156, 156, 156)
                                .addComponent(jButtonCadastrar, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 749, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jLabelEntidade)
                        .addGap(21, 21, 21))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(1, 1, 1)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jTextField11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel13)))
                            .addComponent(jLabel14))
                        .addGap(8, 8, 8)))
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(16, 16, 16)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButtonVoltar)
                            .addComponent(jButtonEditar)
                            .addComponent(jButtonAtualiza)
                            .addComponent(jButtonExcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonAvancar))
                        .addComponent(jButtonCadastrar, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jButtonLimparEntidade))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 209, Short.MAX_VALUE)
                .addGap(12, 12, 12))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonAtualizaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAtualizaActionPerformed
        CarregarEntidade();
        jButtonAvancar.setEnabled(true);
    }//GEN-LAST:event_jButtonAtualizaActionPerformed

    private void jButtonExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExcluirActionPerformed
 if (jTableConsultaEntidade.getSelectedRow() >= 0) {
        int linha = jTableConsultaEntidade.getSelectedRow();    
        Object[] OPTIONS = {"Sim", "Não"};
        String nome_entidade = jTableConsultaEntidade.getValueAt(linha, 1).toString();

        EntidadeDao edao = new EntidadeDao();
        Entidade e = new Entidade();
        e.setNome_ent(nome_entidade);

        try {
            int I = JOptionPane.showOptionDialog(null, "Tem certeza que deseja excluir o registro?", "Excluir", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, OPTIONS, OPTIONS[0]);
            if (I == JOptionPane.YES_OPTION) {
                edao.DeletarEntidade(e);
                JOptionPane.showMessageDialog(this, "Excluído com sucesso!");
                CarregarEntidade();
            }
        } catch (Exception ex) {
            System.out.println("Excluir Entidade - " + ex.getMessage());
        }}else {
           JOptionPane.showMessageDialog(null, "Por favor selecione uma entidade para ser excluido!");
       }   
    }//GEN-LAST:event_jButtonExcluirActionPerformed

    private void jButtonEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEditarActionPerformed
        if (jTableConsultaEntidade.getSelectedRow() >= 0) {
           if (jLabelEntidade.getText().equals("Cliente/Fornecedor")) {
            jButtonEditar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/removeicon.png")));
            jButtonEditar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/removeicon.png")));
            int k = jTableConsultaEntidade.getSelectedRow();
            cod_ent = (Integer) jTableConsultaEntidade.getValueAt(k, 0);

            EntidadeDao edao = new EntidadeDao();
            Entidade e = edao.PesquisarEntidade(cod_ent);

            jTextFieldNome.setText(e.getNome_ent());
            jTextFieldEnd.setText(e.getEnd());
            jTextFieldBairro.setText(e.getBairro());
            jTextFieldUF.setText(e.getUF());
            jTextFieldCidade.setText(e.getCidade());
            jTextFieldCep.setText(e.getCep());
            jTextFieldDDD.setText(e.getDDD());
            jTextFieldTelefone.setText(e.getTelefone());
            jTextFieldCpf.setText(e.getCpf());
            jTextFieldRg.setText(e.getRg());
            jTextField12.setText(e.getObs());
            jTextFieldApelido.setText(e.getApelido());
            jTextFieldIE.setText(e.getIE());
            jTextFieldCNPJ.setText(e.getCnpj());
            jButtonCadastrar.setText("Alterar");
            jLabelEntidade.setText("Alterar Cliente/Fornecedor");
            //pegando o nível selecionado, de acordo com a pesquisa (PesquisarUsuario)
           }else{

            jTextFieldNome.setText("");
            jTextFieldEnd.setText("");
            jTextFieldBairro.setText("");
            jTextFieldUF.setText("");
            jTextFieldCidade.setText("");
            jTextFieldCep.setText("");
            jTextFieldDDD.setText("");
            jTextFieldTelefone.setText("");
            jTextFieldCpf.setText("");
            jTextFieldRg.setText("");
            jTextField12.setText("");
            jTextFieldApelido.setText("");
            jTextFieldIE.setText("");
            jTextFieldCNPJ.setText("");
            jLabelEntidade.setText("Cliente/Fornecedor");
            jButtonCadastrar.setText("Cadastrar");
               
            jButtonEditar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/pencil[2]over.png")));
            jButtonEditar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/pencil.png")));
           }
        } else {
            JOptionPane.showMessageDialog(this, "Favor selecionar a Entidade para ser alterado");
        }

    }//GEN-LAST:event_jButtonEditarActionPerformed

    private void jButtonVoltarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVoltarActionPerformed
        buscarLimiteAnterior();
        jButtonAvancar.setEnabled(true);
}//GEN-LAST:event_jButtonVoltarActionPerformed

    private void jButtonAvancarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAvancarActionPerformed

        BuscarLimiteProximo();
        jButtonVoltar.setEnabled(true);
    }//GEN-LAST:event_jButtonAvancarActionPerformed

    private void jButtonCadastrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCadastrarActionPerformed

        if (jTextFieldNome.getText().isEmpty()) {
            JOptionPane.showMessageDialog(this, "Favor preencher os campos!");
        } else {

            try {
                if (jLabelEntidade.getText().equals("Cliente/Fornecedor")) {
                    Entidade e = new Entidade();
                    EntidadeDao edao = new EntidadeDao();
                    int codent = edao.UltimoCodEnt();

                    DefaultTableModel modelo = (DefaultTableModel) jTableConsultaEntidade.getModel();
                    e.setNome_ent(jTextFieldNome.getText());
                    e.setEnd(jTextFieldEnd.getText());
                    e.setBairro(jTextFieldBairro.getText());
                    e.setUF(jTextFieldUF.getText());
                    e.setCidade(jTextFieldCidade.getText());                   
                    e.setCep(jTextFieldCep.getText());
                    e.setDDD(jTextFieldDDD.getText());
                    e.setTelefone(jTextFieldTelefone.getText());
                    e.setCpf(jTextFieldCpf.getText()); 
                    e.setRg(jTextFieldRg.getText()); 
                    e.setRg(jTextFieldRg.getText());
                    e.setObs(jTextField12.getText());
                    e.setApelido(jTextFieldApelido.getText());
                    e.setIE(jTextFieldIE.getText());
                    e.setCnpj(jTextFieldCNPJ.getText());
                    
                    edao.CadastrarEntidade(e);
               
                    CarregarEntidade();

                    JOptionPane.showMessageDialog(this, "Cadastrado com sucesso!");
                    
                    jTextFieldNome.setText("");
                    jTextFieldEnd.setText("");
                    jTextFieldBairro.setText("");
                    jTextFieldUF.setValue(null);
                    jTextFieldCidade.setText("");
                  //jTextFieldCep.setText("");
                    jTextFieldCep.setValue(null);
                    jTextFieldDDD.setValue(null);
                    jTextFieldTelefone.setValue(null);
                  //jTextFieldCpf.setText("");
                    jTextFieldCpf.setValue(null);
                    jTextFieldRg.setValue(null);
                    jTextField12.setText("");
                    jTextFieldApelido.setText("");
                    jTextFieldIE.setText("");
                    jTextFieldCNPJ.setValue(null);

                } else {
                    Object[] OPTIONS = {"Sim", "Não"};

                    int I = JOptionPane.showOptionDialog(null, "Tem certeza que deseja alterar o registro?", "Alterar", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, OPTIONS, OPTIONS[0]);
                    if (I == JOptionPane.YES_OPTION) {
                        Entidade e = new Entidade();
                        e.setCod_ent(cod_ent);
                        System.out.println(cod_ent);
                        e.setNome_ent(jTextFieldNome.getText());
                        e.setEnd(jTextFieldEnd.getText());
                        e.setBairro(jTextFieldBairro.getText());
                        e.setUF(jTextFieldUF.getText());
                        e.setCidade(jTextFieldCidade.getText());
                        e.setCep(jTextFieldCep.getText());
                        e.setDDD(jTextFieldDDD.getText());
                        e.setTelefone(jTextFieldTelefone.getText());
                        e.setCpf(jTextFieldCpf.getText());
                        e.setRg(jTextFieldRg.getText());
                        e.setObs(jTextField12.getText());
                        e.setApelido(jTextFieldApelido.getText());
                        e.setIE(jTextFieldIE.getText());
                        e.setCnpj(jTextFieldCNPJ.getText());
                        EntidadeDao edao = new EntidadeDao();
                        edao.AlterarEntidade(e);

                        JOptionPane.showMessageDialog(this, "Alterado com sucesso!");
                        
                        jTextFieldNome.setText("");
                    jTextFieldEnd.setText("");
                    jTextFieldBairro.setText("");
                    jTextFieldUF.setValue(null);
                    jTextFieldCidade.setText("");
                  //  jTextFieldCep.setText("");
                    jTextFieldCep.setValue(null);
                    jTextFieldDDD.setValue(null);
                    jTextFieldTelefone.setValue(null);
              //      jTextFieldCpf.setText("");
                  jTextFieldCpf.setValue(null);
                    jTextFieldRg.setValue(null);
                    jTextField12.setText("");
                    jTextFieldApelido.setText("");
                    jTextFieldIE.setText("");
                    jTextFieldCNPJ.setValue(null);
                        
                        jLabelEntidade.setText("Cliente/Fornecedor");
                        jButtonCadastrar.setText("Cadastrar");
                        jButtonEditar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/pencil[2]over.png")));
                        jButtonEditar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/pencil.png")));

                    }
                    CarregarEntidade();
                }
            } catch (Exception ex) {
                System.out.println("Cadastrar Entidade - " + ex.getMessage());
            }
        }
    }//GEN-LAST:event_jButtonCadastrarActionPerformed

    private void jTextField11KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField11KeyReleased
        CarregarEntidadeLetra();        
    }//GEN-LAST:event_jTextField11KeyReleased

    private void jTextFieldDDDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldDDDActionPerformed
         
    }//GEN-LAST:event_jTextFieldDDDActionPerformed

    private void jTextFieldCepActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldCepActionPerformed
         
    }//GEN-LAST:event_jTextFieldCepActionPerformed

    private void jTextFieldCpfFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldCpfFocusLost
         
if(jTextFieldCpf.getText().equals("   .   .   -  ")){   
                 jTextFieldCpf.setValue(null);
}
    }//GEN-LAST:event_jTextFieldCpfFocusLost

    private void jTextFieldCpfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldCpfActionPerformed
         
    }//GEN-LAST:event_jTextFieldCpfActionPerformed

    private void jTextFieldTelefoneFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldTelefoneFocusLost
         
if(jTextFieldTelefone.getText().equals("    -    ")){   
                   jTextFieldTelefone.setValue(null);
}
    }//GEN-LAST:event_jTextFieldTelefoneFocusLost

    private void jTextFieldDDDFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldDDDFocusLost
         
if(jTextFieldDDD.getText().equals("(  )")){   
                   jTextFieldDDD.setValue(null);
}
    }//GEN-LAST:event_jTextFieldDDDFocusLost

    private void jTextFieldCepFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldCepFocusLost
         
if(jTextFieldCep.getText().equals("     -   ")){   
                   jTextFieldCep.setValue(null);
}
    }//GEN-LAST:event_jTextFieldCepFocusLost

    private void jTextFieldUFFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldUFFocusLost
         
if(jTextFieldUF.getText().equals("  ")){   
                   jTextFieldUF.setValue(null);
}
    }//GEN-LAST:event_jTextFieldUFFocusLost

    private void jTextFieldRgFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldRgFocusLost
         
if(jTextFieldRg.getText().equals("  .   .   - ")){   
                   jTextFieldRg.setValue(null);
}
    }//GEN-LAST:event_jTextFieldRgFocusLost

    private void jTextFieldCNPJFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldCNPJFocusLost
         
if(jTextFieldCNPJ.getText().equals("   .   .   /    -  ")){   
                   jTextFieldCNPJ.setValue(null);
}
    }//GEN-LAST:event_jTextFieldCNPJFocusLost

    private void jButtonLimparEntidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLimparEntidadeActionPerformed
         
        jTextFieldNome.setText("");
                    jTextFieldEnd.setText("");
                    jTextFieldBairro.setText("");
                    jTextFieldUF.setValue(null);
                    jTextFieldCidade.setText("");
                  //  jTextFieldCep.setText("");
                    jTextFieldCep.setValue(null);
                    jTextFieldDDD.setValue(null);
                    jTextFieldTelefone.setValue(null);
              //      jTextFieldCpf.setText("");
                  jTextFieldCpf.setValue(null);
                    jTextFieldRg.setValue(null);
                    jTextField12.setText("");
                    jTextFieldApelido.setText("");
                    jTextFieldIE.setText("");
                    jTextFieldCNPJ.setValue(null);
    }//GEN-LAST:event_jButtonLimparEntidadeActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FrameEntidade().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonAtualiza;
    private javax.swing.JButton jButtonAvancar;
    private javax.swing.JButton jButtonCadastrar;
    private javax.swing.JButton jButtonEditar;
    private javax.swing.JButton jButtonExcluir;
    private javax.swing.JButton jButtonLimparEntidade;
    private javax.swing.JButton jButtonVoltar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelEntidade;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTableConsultaEntidade;
    private javax.swing.JTextField jTextField11;
    private javax.swing.JTextField jTextField12;
    private javax.swing.JTextField jTextFieldApelido;
    private javax.swing.JTextField jTextFieldBairro;
    private javax.swing.JFormattedTextField jTextFieldCNPJ;
    private javax.swing.JFormattedTextField jTextFieldCep;
    private javax.swing.JTextField jTextFieldCidade;
    private javax.swing.JFormattedTextField jTextFieldCpf;
    private javax.swing.JFormattedTextField jTextFieldDDD;
    private javax.swing.JTextField jTextFieldEnd;
    private javax.swing.JFormattedTextField jTextFieldIE;
    private javax.swing.JTextField jTextFieldNome;
    private javax.swing.JFormattedTextField jTextFieldRg;
    private javax.swing.JFormattedTextField jTextFieldTelefone;
    private javax.swing.JFormattedTextField jTextFieldUF;
    // End of variables declaration//GEN-END:variables
}
